<?php


namespace App\Study\ObServer;


class Event
{
    private $observers;
    //增加观察者
    public function add(IObserver $observer)
    {
        $this->observers[] = $observer;
    }

    public function notify()
    {
        /** @var IObserver $observer */
        foreach ($this->observers as $observer){
            $observer->update();
        }
    }

    public function trigger()
    {
        $this->notify();
    }
}
